<script setup>
  import { onLoad,onShow } from '@dcloudio/uni-app'
import { onMounted, ref } from "vue";
import { uniFetch } from '../../utils/fetch';

  // 获取地址参数
  onLoad((params) => {
    console.log(params)
		getdata(params.id)
  })
  const info=ref({});
	const getdata=(e)=>{
		console.log(e);
uniFetch({
	url:`/driver/tasks/details/${e}`
}).then(res=>{
	console.log(res,"ress");
	info.value=res.data.data
})
	}
</script>

<template>
  <view class="page-container">
    <view class="search-bar">
      <text class="iconfont icon-scan"></text>
      <input class="input" type="text" placeholder="输入运单号" />
    </view>
    <scroll-view scroll-y class="task-detail">
      <view class="scroll-view-wrapper">
        <view class="basic-info panel">
          <view class="panel-title">基本信息</view>
          <view class="timeline">
            <view class="line"
              >{{info.startAddress}}</view
            >
            <view class="line">{{info.endAddress}}</view>
            <navigator
              hover-class="none"
              url="/subpkg_task/guide/index"
              class="guide"
            >
              <text class="iconfont icon-guide"></text>
              <text>开始导航</text>
            </navigator>
          </view>
          <view class="info-list">
            <view class="info-list-item">
              <text class="label">任务编号</text>
              <text class="value">{{info.transportTaskId}}</text>
            </view>
			<template v-if="info.status == 1">

            <view class="info-list-item">
              <text class="label">提货联系人</text>
              <text class="value">{{info.startHandoverName}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">联系电话</text>
              <text class="value">{{info.startHandoverPhone}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">预计提货时间</text>
              <text class="value">{{info.planDepartureTime}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">实际提货时间</text>
              <text class="value">{{info.actualDepartureTime}}</text>
            </view>
			</template>

            <view class="hr"></view>
<template v-if="info.status === 2">
            <view class="info-list-item">
              <text class="label">交付联系人</text>
              <text class="value">{{info.finishHandoverName}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">联系电话</text>
              <text class="value">{{info.finishHandoverPhone}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">预计送达时间</text>
              <text class="value">{{info.planArrivalTime}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">实际送达时间</text>
              <text class="value">{{info.actualArrivalTime}}</text>
            </view>
			</template>
          </view>
        </view>

        <view class="except-info panel">
          <view class="panel-title">异常信息</view>
          <view class="info-list" v-for="item in info.exceptionList">
            <view class="info-list-item">
              <text class="label">上报时间</text>
              <text class="value">{{item.exceptionTime}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">异常类型</text>
              <text class="value">{{item.exceptionType}}</text>
            </view>
            <view class="info-list-item">
              <text class="label">处理结果</text>
              <text class="value">{{item.handleResult}}</text>
            </view>
          </view>
         
        </view>

        <view class="panel pickup-info" v-if="info.status>=2">
          <view class="panel-title">提货信息</view>
          <view class="label">提货凭证</view>
          <view class="pictures" >
            <image class="picture" v-if="info.cargoPickUpPictureList!==null" v-for="item in info.cargoPickUpPictureList" :src="item.url" mode=""></image>
            
            <view v-if="info.cargoPickUpPictureList==null" class="picture-blank">暂无图片</view>
          </view>
          <view class="label">货品照片</view>
          <view class="pictures">
            <image class="picture" v-if="info.cargoPictureList!==null" v-for="item in info.cargoPictureList"  :src="item.url" mode=""></image>
           
            <view v-if="info.cargoPictureList==null" class="picture-blank">暂无图片</view>
          </view>
        </view>

        <view class="delivery-info panel" v-if="info.status==4||info.status==6">
          <view class="panel-title">交货信息</view>
          <view class="label">交货凭证</view>
          <view class="pictures">
            <image class="picture"  v-for="item in info.certificatePictureList" :src="item.url" mode=""></image>
            
            <view v-if="info.certificatePictureList == null" class="picture-blank">暂无图片</view>
          </view>
          <view class="label">货品照片</view>
          <view class="pictures">
          <image class="picture"  v-for="item in info.deliverPictureList" :src="item.url" mode=""></image>
            
            <view v-if="info.deliverPictureList == null" class="picture-blank">暂无图片</view>
          
          </view>
        </view>
      </view>
    </scroll-view>

    <view class="toolbar" v-if="info.status === 1">
      <navigator

       
        :url="`/subpkg_task/delay/index?id=${info.id}&planDepartureTime=${info.planDepartureTime}`"
        hover-class="none"
        class="button secondary"
        >延迟提货</navigator
      >
      <navigator

     
        :url="`/subpkg_task/pickup/index?id=${info.id}`"

        hover-class="none"
        class="button primary"
        >提货</navigator
      >
    </view>
    <view class="toolbar" v-if="info.status === 2">
      <navigator
        :url="`/subpkg_task/except/index?id=${info.transportTaskId}`"
        hover-class="none"
        class="button secondary"
        >异常上报
      </navigator>
      <navigator
        :url="`/subpkg_task/delivery/index?id=${info.id}`"
        hover-class="none"
        class="button primary"
        >支付</navigator
      >
    </view>
    <view class="toolbar" v-if="info.status === 4">
      <navigator
        :url="`/subpkg_task/record/index?id=${info.id}&&actualArrivalTime=${info.actualArrivalTime}`"
        hover-class="none"
        class="button primary block"
        >回车登记</navigator
      >
    </view>
  </view>
</template>

<style lang="scss" scoped>
  @import './index.scss';
</style>
